package cn.dengta.webapp.user.entity.game;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import cn.dengta.webapp.user.model.GameType;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.Cmp;
import me.codeplayer.util.StringUtil;

/**
 * 游戏基本信息
 *
 * @author Ready
 * @since 2022-10-26
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("dt_game")
public class Game extends TimeBasedEntity {

	private static final long serialVersionUID = 1L;
	private static int download = -9;
	private static int init = 0;
	private static int normal = 9;
	/** 别名 */
	String alias;
	/** 名称 */
	String name;
	/** 图标路径 */
	String icon;
	/** 游戏连接地址 */
	String link;
	/** 游戏类型id */
	GameType typeId;
	/** -9=下架；0=初始化；9=上架 */
	Integer status;
	/** 详情 */
	String details;
	/** 排序 降序 */
	Integer sort;
	/** 白名单用户，多个英文逗号分隔 */
	String whitelist;
	/** 角标路径 */
	String tagUrl;

	/** 是否上架 */
	public boolean isNormal(Long userId) {
		return Cmp.eq(this.status, normal) ||
				userId != null && StringUtil.notEmpty(whitelist) && StringUtil.containsWord(whitelist, userId.toString(), ",");
	}

	public static final String ALIAS = "alias";
	public static final String NAME = "name";
	public static final String ICON = "icon";
	public static final String LINK = "link";
	public static final String TYPE_ID = "type_id";
	public static final String STATUS = "status";
	public static final String DETAILS = "details";
	public static final String SORT = "sort";

	public static class Alias {
		/** 小鸟 */
		public static final String alias_bird = "bird";
		/** 跳一跳 */
		public static final String alias_jump = "jump";
		/** 转盘 */
		public static final String alias_roulette = "roulette";
		/** 骰子 */
		public static final String alias_dice = "dice";

	}

}
